In this part of the workshop you will extend our bot with the capability to create an issue in GitHub. We will build a logic app with 3 steps. We will use Request / Response Step Connector for invoking the Logic App and providing the final response where our second step will be creating a GitHub issue. Please refer to the diagram below showing the steps in logic app.
This project provides the following features:
- Create GitHub Issue
- Provide link to the created GitHub issue in the response
-
You need to have GitHub account with a repo, if you don’t please create one here https://github.com - or you can use the provided account:
Username: [email protected] Password: S3rverless1 -
Access to Azure Subscription, please check here https://portal.azure.com
-
Bot Framework Emulator - https://github.com/Microsoft/BotFramework-Emulator/releases/
-
Login to Azure Portal and Create new Logic App
- If you don’t see it on your left menu you can search for it via More Services on the bottom
- Then type Logic Apps in the Search Bar
- Press Add button
- And fill the required data and press Create button at the bottom
-
Next, we will configure the Logic App. In the Logic Apps Designer please select “Blank Logic App” from the Templates section
- In the Connector Search select Request / Response Connector
- Press “Use sample payload to generate schema” button
-
And paste the following JSON
{ "title": "My new issue", "text": "My new issue description" }
-
The contron should look like the picture below. Next press Done
- The result will look like
- Then press “New Step” button, select “Add an action” and select GitHub Connector with Action – “Create an issue”
- Next, please select Sign In and input your GitHub account credentials and fill the required data that will be used for creating the GitHub issue
- For title and body will pick dynamic content fields - title and text. Also set the correct repository and its owner. If using the associated GitHub account ([email protected]) there is a repo already set up. You can use this info only if you authenticated with the demo account. If not use a repo in your own GitHub.
Repo Owner: azuerserverlessdemo
Repo Name: squirebotdemo
Title: You can pass in the title from the trigger here.
Text: You can pass in the text from the trigger here.
- Press “New step” and search for Response and select Request - Response step:
- Next we will configure the step by selecting 200 for response code, specifying the repository and its owner. It is also very important to define the body with the following json object. Squire bot will expect message propery in the body object to display the final message to the user:
{ "message": "[GitHub Issue Link](https://github.com/{input-repo-owner}/{input-repo}/issues/@{body('Create_an_issue')?['number']})" }
-
We use dynamic value for issue ID when constructing the link. We use Markdown format for the message content:
-
Save your work and now you are ready to test. Go to the Request / Response connector step and copy the URL
-
If you want to your logic app immediatelly, go to Postman or similar app and POST to the provided URL. Do not forget to set Content-Type header to “application/json”
-
For the body use the JSON schema we defined several steps ago
-
You can go to your Logic App home screen and see the history of execution and troubleshoot
-
Now it is time to integrate GitHub Bot with the Squire Bot. Please follow the instructions for running locally the Squire Bot. And then copy the POST URL of the logic app we created in order to setup new task for Squire Bot. It should look very similar to the image below:
-
Next start Bot Framework Emulator and connect to http://localhost:7071/api/bot . And now are you are ready to test GitHub Issuer via the Squire Bot. Please type the name of the task you created to start the conversation and the interaction should be very similar to the screenshot below:
Congratulations! You competed the module!
You have just added GitHub issue creation as a new capability of our always improving bot!
Thank you!