@aries-framework/question-answer
TypeScript icon, indicating that this package has built-in type declarations

0.4.2 • Public • Published


Hyperledger Aries logo

Aries Framework JavaScript Question Answer Module

License typescript @aries-framework/question-answer version


Question Answer module for Aries Framework JavaScript. Implements Aries RFC 0113.

Installation

Make sure you have set up the correct version of Aries Framework JavaScript according to the AFJ repository. To find out which version of AFJ you need to have installed you can run the following command. This will list the required peer dependency for @aries-framework/core.

npm info "@aries-framework/question-answer" peerDependencies

Then add the question-answer module to your project.

yarn add @aries-framework/question-answer

Quick start

In order for this module to work, we have to inject it into the agent to access agent functionality. See the example for more information.

Example of usage

import { QuestionAnswerModule } from '@aries-framework/question-answer'

const agent = new Agent({
  config: {
    /* config */
  },
  dependencies: agentDependencies,
  modules: {
    questionAnswer: new QuestionAnswerModule(),
    /* other custom modules */
  },
})

await agent.initialize()

// To send a question to a given connection
await agent.modules.questionAnswer.sendQuestion(connectionId, {
  question: 'Do you want to play?',
  validResponses: [{ text: 'Yes' }, { text: 'No' }],
})

// Questions and Answers are received as QuestionAnswerStateChangedEvent

// To send an answer related to a given question answer record
await agent.modules.questionAnswer.sendAnswer(questionAnswerRecordId, 'Yes')

Readme

Keywords

none

Package Sidebar

Install

npm i @aries-framework/question-answer

Weekly Downloads

1,352

Version

0.4.2

License

Apache-2.0

Unpacked Size

79.1 kB

Total Files

60

Last publish

Collaborators

  • openwalletfoundation
  • hyperledger-ghci
  • timoglastra
  • hyperledger-lf