Skip to content
This repository was archived by the owner on Sep 24, 2019. It is now read-only.

Latest commit

 

History

History
146 lines (82 loc) · 6.12 KB

File metadata and controls

146 lines (82 loc) · 6.12 KB

GitHub Issue Bot

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.

Architecture

Features

This project provides the following features:

  • Create GitHub Issue
  • Provide link to the created GitHub issue in the response

Getting Started

Prerequisites

  1. 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

  2. Access to Azure Subscription, please check here https://portal.azure.com

  3. Bot Framework Emulator - https://github.com/Microsoft/BotFramework-Emulator/releases/

Walkthrough

  • 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

    Azure Menu

    • Then type Logic Apps in the Search Bar

    Logic App Search

    • Press Add button

    Add Logic App

    • And fill the required data and press Create button at the bottom

    Logic App Parameters

  • Next, we will configure the Logic App. In the Logic Apps Designer please select “Blank Logic App” from the Templates section

    Logic App Parameters

    • In the Connector Search select Request / Response Connector

    Logic App Request

    • Press “Use sample payload to generate schema” button

    Logic App Request Body

    • 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

    JSON object

    • The result will look like

    JSON schema

    • Then press “New Step” button, select “Add an action” and select GitHub Connector with Action – “Create an issue”

    Github step

    • 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

    Github data

    • 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.

    Github dynamic data

    • Press “New step” and search for Response and select Request - Response step:

    Slack post message

    • 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:

      Slack post message

    • Save your work and now you are ready to test. Go to the Request / Response connector step and copy the URL URL capturing

    • 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”

      Postman testing 1

    • For the body use the JSON schema we defined several steps ago Postman testing 2

    • You should receive the following reponse in Postman: Slack post

    • You can go to your Logic App home screen and see the history of execution and troubleshoot Logic app executions

    • 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: Squire Bot GitHub Setup

    • 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:

    Squire Bot GitHub Task Test

    • And if you click on the link in the last message you will be able to open the GitHub Issue we just created via Squire Bot:

      GitHub Issue

Congratulations! You competed the module!

You have just added GitHub issue creation as a new capability of our always improving bot!

Thank you!