{"id":20415694,"url":"https://github.com/emimontesdeoca/integration-test-directline-bot-framework","last_synced_at":"2026-04-20T06:33:15.903Z","repository":{"id":38409030,"uuid":"129097248","full_name":"emimontesdeoca/integration-test-directline-bot-framework","owner":"emimontesdeoca","description":":robot: Integration testing for Bots based in Microsoft Bot Framework's Direct Line","archived":false,"fork":false,"pushed_at":"2022-06-23T09:20:37.000Z","size":60,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-15T13:56:43.999Z","etag":null,"topics":["bot","conversation","directline","flow","flow-cases","json","microsoft-bot-framework"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/emimontesdeoca.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-11T13:22:20.000Z","updated_at":"2022-06-23T09:20:30.000Z","dependencies_parsed_at":"2022-08-25T02:50:13.961Z","dependency_job_id":null,"html_url":"https://github.com/emimontesdeoca/integration-test-directline-bot-framework","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emimontesdeoca%2Fintegration-test-directline-bot-framework","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emimontesdeoca%2Fintegration-test-directline-bot-framework/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emimontesdeoca%2Fintegration-test-directline-bot-framework/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emimontesdeoca%2Fintegration-test-directline-bot-framework/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/emimontesdeoca","download_url":"https://codeload.github.com/emimontesdeoca/integration-test-directline-bot-framework/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241960833,"owners_count":20049342,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bot","conversation","directline","flow","flow-cases","json","microsoft-bot-framework"],"created_at":"2024-11-15T06:17:15.047Z","updated_at":"2026-04-20T06:33:10.878Z","avatar_url":"https://github.com/emimontesdeoca.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Integration test for Microsoft's Bot Framework using Direct Line channel\n\nThis repository has a test solution in Visual Studio that does integration test for Microsoft's Bot Framework using the DirectLine channel.\n\n## Table of contents\n\n- [Working flow](https://github.com/emimontesdeoca/integration-test-directline-bot-framework#working-flow)\n- [Project tree](https://github.com/emimontesdeoca/integration-test-directline-bot-framework#project-tree)\n  - [Auth](https://github.com/emimontesdeoca/integration-test-directline-bot-framework#auth)\n  - [Collections](https://github.com/emimontesdeoca/integration-test-directline-bot-framework#collections)\n  - [Objects](https://github.com/emimontesdeoca/integration-test-directline-bot-framework#objects)\n  - [Tests](https://github.com/emimontesdeoca/integration-test-directline-bot-framework#tests)\n  - [Utils](https://github.com/emimontesdeoca/integration-test-directline-bot-framework#utils)\n- [JSON structure](https://github.com/emimontesdeoca/integration-test-directline-bot-framework#json-structure)\n- [Building the JSON](https://github.com/emimontesdeoca/integration-test-directline-bot-framework#working-flow)\n  - [Requirements](https://github.com/emimontesdeoca/integration-test-directline-bot-framework#requirements)\n  - [Build the main structure of the JSON](https://github.com/emimontesdeoca/integration-test-directline-bot-framework#build-the-main-structure-of-the-json)\n  - [Building an entry](https://github.com/emimontesdeoca/integration-test-directline-bot-framework#building-an-entry)\n  - [Filling the steps](https://github.com/emimontesdeoca/integration-test-directline-bot-framework#filling-the-steps)\n    - [Sending a message and getting the Activity](https://github.com/emimontesdeoca/integration-test-directline-bot-framework#sending-a-message-and-getting-the-activity)\n    - [Receiving a message and getting the Activity](https://github.com/emimontesdeoca/integration-test-directline-bot-framework#receiving-a-message-and-getting-the-activity)\n    - [Building the assert](https://github.com/emimontesdeoca/integration-test-directline-bot-framework#building-the-assert)\n    - [Not asserting the message](https://github.com/emimontesdeoca/integration-test-directline-bot-framework#filling-the-steps)\n- [Contributing](https://github.com/emimontesdeoca/integration-test-directline-bot-framework#contributing)\n- [License](https://github.com/emimontesdeoca/integration-test-directline-bot-framework#license)\n\n\n## Working flow\n\n[![https://gyazo.com/1203e163e730af4f1b3dcbf2af649a05](https://i.gyazo.com/1203e163e730af4f1b3dcbf2af649a05.png)](https://gyazo.com/1203e163e730af4f1b3dcbf2af649a05)\n\n## Project tree\n\nI've separated the classes by folders as you can see in the following tree.\n\n```\n│\n├───Auth\n│       DirectLineAuth.cs\n│\n├───Collections\n│       TestEntriesCollection.cs\n│\n├───Objects\n│       TestEntry.cs\n│       TestSteps.cs\n│\n├───Tests\n│       DirectLineTests.cs\n│       FileTests.cs\n│       IntegrationTests.cs\n│\n└───Utils\n        ActivityResponse.cs\n        API.cs\n        Data.cs\n        Globals.cs\n```\n\n#### Auth\n\n* `DirectLineAuth.cs` contains the object for the received json in the authorization process.\n\n#### Collections\n\n* `TestEntriesCollection.cs` contains the object for the json that contains the information and the entries.\n\n#### Objects\n\n* `TestEntry.cs` contains the object for the json that contains the entry to test.\n* `TestSteps.cs` contains the object for the json that contains the step that will be made by the bot.\n\n#### Tests\n\n* `DirectLineTests.cs` contains the testing cases for the authetication.\n* `FileTests.cs` contains the testing cases for the file.\n* `IntegrationTests.cs` contains thetesting for the integration test cases.\n\n#### Utils\n\n* `ActivityResponse.cs` contains the object for the reveiced json when asking for all the messages in a determined conversation.\n* `Globals.cs` contains the object for loading the objects in the CodeAnalysis evaluator.\n* `Data.cs` contains the string for the cases file path.\n* `API.cs` contains functions for API calls.\n\n## JSON structure\n\nThe json structure contains all the information necessary for the bot.\n\n* **_`string`_** `secret`: DirectLine secret\n* **_`string`_** `directlineGenerateTokenEndpoint`: DirectLine endpoint to get the token\n* **_`string`_** `directlineConversationEndpoint`: DirectLine endpoint to get the conversation\n* **_`List\u003cTestEntry\u003e`_** `entries`: Cases\n  * **_`string`_** `name`: Case name\n  * **_`string`_** `description`: Case description\n  * **_`bool`_** `mute`: Enable or disable the case, set this to true to not test the case\n  * **_`List\u003cTestSteps\u003e`_** `steps`: Steps to do in the case\n    * **_`Activity`_** `request`: Request to the bot as `Activity`\n    * **_`Activity`_** `response`: Request to the bot as `Activity`\n    * **_`bool`_** `assert`: Assert string to do, have to return a boolean.\n\n```json\n{\n  \"secret\": \"YourDirectLineChatSecret\",\n  \"directlineGenerateTokenEndpoint\": \"https://directline.botframework.com/v3/directline/tokens/generate\",\n  \"directlineConversationEndpoint\": \"https://directline.botframework.com/v3/directline/conversations/\",\n  \"entries\": [\n    {\n      \"name\": \"CaseName\",\n      \"description\": \"CaseDescription\",\n      \"mute\":  false ,\n      \"steps\": [\n        {\n          \"request\": {\n           /* Request as activity */\n          },\n          \"response\": {\n            /* Response as activity*/\n          },\n          \"assert\": /* Assert as string, have to return boolean */\n        },\n         {\n          \"request\": {\n           /* Request as activity */\n          },\n          \"response\": {\n             /* Response as activity*/\n          },\n          \"assert\": /* Assert as string, have to return boolean */\n        },\n         {\n          \"request\": {\n           /* Request as activity */\n          },\n          \"response\": {\n             /* Response as activity*/\n          },\n          \"assert\": /* Assert as string, have to return boolean */\n        }\n      ]\n    }\n  ]\n}\n```\n\n## Building the JSON\n\n### Requirements\n\n1.  [Microsoft Bot Framework Emulator (V4 PREVIEW)](https://github.com/Microsoft/BotFramework-Emulator)\n2.  [DirectLine Secret](https://docs.microsoft.com/en-us/azure/bot-service/rest-api/bot-framework-rest-direct-line-3-0-authentication?view=azure-bot-service-3.0#get-a-direct-line-secret)\n3.  [DirectLine token generation endpoint](https://docs.microsoft.com/en-us/azure/bot-service/rest-api/bot-framework-rest-direct-line-3-0-authentication?view=azure-bot-service-3.0#generate-token), at the moment of this guide is `https://directline.botframework.com/v3/directline/tokens/generate`.\n4.  [DirectLine conversation creation endpoint](https://directline.botframework.com/v3/directline/conversations), at the moment of this guide is `https://directline.botframework.com/v3/directline/conversations`.\n5.  Any text editor to build the JSON.\n\n### Build the main structure of the JSON\n\nHere will be the main configuration for the JSON file.\n\n```json\n{\n  \"secret\": /* Secret from DirectLine */,\n  \"directlineGenerateTokenEndpoint\": /* DirectLine token endpoint from above */,\n  \"directlineConversationEndpoint\": /* DirectLine conversation token from above */,\n  \"entries\": [\n    /* Here will be the cases */\n  ]\n}\n```\n\n### Building an entry\n\nAn entry contains some information about it: `name`, `description`, `mute` and `steps`.\n\n```\n{\n    \"name\": /* Here will be the case name */,\n    \"description\": /* Here will be the case description */,\n    \"mute\":  /* Here will be if the case is enabled or not*/,\n    \"steps\": [\n      {\n        \"request\": {\n          /* Request as activity */\n        },\n        \"response\": {\n          /* Response as activity*/\n        },\n        \"assert\": /* Assert as string, have to return boolean */\n      },\n        {\n        \"request\": {\n          /* Request as activity */\n        },\n        \"response\": {\n            /* Response as activity*/\n        },\n        \"assert\": /* Assert as string, have to return boolean */\n      },\n        {\n        \"request\": {\n          /* Request as activity */\n        },\n        \"response\": {\n            /* Response as activity*/\n        },\n        \"assert\": /* Assert as string, have to return boolean */\n      }\n    ]\n  }\n```\n\n### Filling the steps\n\nIn order to fill the steps, we need to use the [Microsoft Bot Framework Emulator (V4 PREVIEW)](https://github.com/Microsoft/BotFramework-Emulator), using this application we can easily read all the serialized `Activity` that we are sending/receiving.\n\n#### Sending a message and getting the `Activity`\n\nPick the message you want, to send and add it to the `request`.\n\n\u003ca href=\"https://gyazo.com/043c789136942c028cd6d30799f9a0ec\"\u003e\u003cimg align=\"center\" src=\"https://i.gyazo.com/043c789136942c028cd6d30799f9a0ec.png\" alt=\"https://gyazo.com/043c789136942c028cd6d30799f9a0ec\" width=\"1141\"/\u003e\u003c/a\u003e\n\nSo far the `step` looks like this:\n\n```\n{\n  \"request\": {\n    \"channelData\": {\n      \"clientActivityId\": \"112983719237123798\"\n    },\n    \"entities\": [\n      {\n        \"requiresBotState\": true,\n        \"supportsListening\": true,\n        \"supportsTts\": true,\n        \"type\": \"ClientCapabilities\"\n      }\n    ],\n    \"from\": {\n      \"id\": \"default-user\",\n      \"name\": \"User\"\n    },\n    \"id\": \"7b2c9300-6002131313131317830d951\",\n    \"locale\": \"es\",\n    \"text\": \"Hola\",\n    \"textFormat\": \"plain\",\n    \"timestamp\": \"2018-05-25T10:00:40.747Z\",\n    \"type\": \"message\"\n  },\n  \"response\": {},\n  \"assert\": \"\"\n}\n```\n\n#### Receiving a message and getting the `Activity`\n\nPick the message that you will be comparing and add it to the `response`.\n\n**Message should be the last message you will receive, for example: if you ask `hi` and the bot returns `3` messages, you have to add the last one**\n\n\u003ca href=\"https://gyazo.com/df58224b4205d014f0bc5fe921f6a5e4\"\u003e\u003cimg  align=\"center\" src=\"https://i.gyazo.com/df58224b4205d014f0bc5fe921f6a5e4.png\" alt=\"https://gyazo.com/df58224b4205d014f0bc5fe921f6a5e4\" width=\"1137\"/\u003e\u003c/a\u003e\n\nWe have the respone now, o far the `step` looks like this:\n\n```\n{\n  \"request\": {\n    \"channelData\": {\n      \"clientActivityId\": \"112983719237123798\"\n    },\n    \"entities\": [\n      {\n        \"requiresBotState\": true,\n        \"supportsListening\": true,\n        \"supportsTts\": true,\n        \"type\": \"ClientCapabilities\"\n      }\n    ],\n    \"from\": {\n      \"id\": \"default-user\",\n      \"name\": \"User\"\n    },\n    \"id\": \"7b2c9300-6002131313131317830d951\",\n    \"locale\": \"es\",\n    \"text\": \"Hola\",\n    \"textFormat\": \"plain\",\n    \"timestamp\": \"2018-05-25T10:00:40.747Z\",\n    \"type\": \"message\"\n  },\n  \"response\": {\n    \"attachments\": [],\n    \"channelId\": \"emulator\",\n    \"conversation\": {\n      \"id\": \"74a9db50-600asdasdadb28|livechat\"\n    },\n    \"entities\": [],\n    \"from\": {\n      \"id\": \"ba2e1c30-asdasd54fafccc92\",\n      \"name\": \"Bot\"\n    },\n    \"id\": \"7be079b0-6002-11e8-b284-ffdb7830d951\",\n    \"localTimestamp\": \"2018-05-25T11:00:41+01:00\",\n    \"locale\": \"es\",\n    \"membersAdded\": [],\n    \"membersRemoved\": [],\n    \"reactionsAdded\": [],\n    \"reactionsRemoved\": [],\n    \"recipient\": {\n      \"id\": \"default-user\",\n      \"role\": \"user\"\n    },\n    \"replyToId\": \"7b2c93asdasdasddb7830d951\",\n    \"serviceUrl\": \"https://aaae2b27.ngrok.io\",\n    \"text\": \"Selecciona una de las siguientes opciones:\",\n    \"timestamp\": \"2018-05-25T10:00:41.931Z\",\n    \"type\": \"message\"\n  },\n  \"assert\": \"\"\n}\n```\n\n#### Building the assert\n\nIn order to make the assert, the string evaluation has to return a `boolean`, a few examples:\n\n1.  `\"Response.Attachments.Count \u003e= 3\"`\n2.  `\"Response.Text == \\\"Message\\\"\"`\n3.  `\"Response.Attachments[0].Text == \"Hello\"\"`\n\nIn this case we will be comparing to the text, so our `assert` value will be:\n\n`\"assert\": Response.Text == \\\"Selecciona una de las siguientes opciones:\\\"\"`.\n\nIn the end, our step will be like this:\n\n```\n{\n  \"request\": {\n    \"channelData\": {\n      \"clientActivityId\": \"112983719237123798\"\n    },\n    \"entities\": [\n      {\n        \"requiresBotState\": true,\n        \"supportsListening\": true,\n        \"supportsTts\": true,\n        \"type\": \"ClientCapabilities\"\n      }\n    ],\n    \"from\": {\n      \"id\": \"default-user\",\n      \"name\": \"User\"\n    },\n    \"id\": \"7b2c9300-6002131313131317830d951\",\n    \"locale\": \"es\",\n    \"text\": \"Hola\",\n    \"textFormat\": \"plain\",\n    \"timestamp\": \"2018-05-25T10:00:40.747Z\",\n    \"type\": \"message\"\n  },\n  \"response\": {\n    \"attachments\": [],\n    \"channelId\": \"emulator\",\n    \"conversation\": {\n      \"id\": \"74a9db50-6asdasdasdb28|livechat\"\n    },\n    \"entities\": [],\n    \"from\": {\n      \"id\": \"ba2e1c30-5360-1asdasdasdfafccc92\",\n      \"name\": \"Bot\"\n    },\n    \"id\": \"7be079b0-60asdasdasddb7830d951\",\n    \"localTimestamp\": \"2018-05-25T11:00:41+01:00\",\n    \"locale\": \"es\",\n    \"membersAdded\": [],\n    \"membersRemoved\": [],\n    \"reactionsAdded\": [],\n    \"reactionsRemoved\": [],\n    \"recipient\": {\n      \"id\": \"default-user\",\n      \"role\": \"user\"\n    },\n    \"replyToId\": \"7b2c9300-60asdasdasdffdb7830d951\",\n    \"serviceUrl\": \"https://aaae2b27.ngrok.io\",\n    \"text\": \"Selecciona una de las siguientes opciones:\",\n    \"timestamp\": \"2018-05-25T10:00:41.931Z\",\n    \"type\": \"message\"\n  },\n  \"assert\": Response.Text == \\\"Selecciona una de las siguientes opciones:\\\"\"\n}\n```\n\nSo with this example, you can add more steps to the main JSON and make a flow conversation.\n\n#### Not asserting the message\n\nIf you just want to send a message without testing it, all you have to do is to leave empty the `assert`.\n\n## Contributing\n\nAs a developer, if you feel like helping, any contribution is welcome.\n\nAnd as user, if youy have any bug, issue, feature request or question, feel free to open a [ticket issue](https://github.com/emimontesdeoca/integration-test-directline-bot-framework/issues).\n\n## License\n\nMIT License\n\nCopyright (c) 2018 Emiliano Montesdeoca del Puerto\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femimontesdeoca%2Fintegration-test-directline-bot-framework","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femimontesdeoca%2Fintegration-test-directline-bot-framework","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femimontesdeoca%2Fintegration-test-directline-bot-framework/lists"}