How to use botframework-webchat-core - 8 common examples

To help you get started, we’ve selected a few botframework-webchat-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / BotFramework-Emulator / packages / app / client / src / state / sagas / chatSagas.ts View on Github external
public static *newChat(action: ChatAction>): Iterable {
    const { documentId, resolver } = action.payload;
    // Create a new webchat store for this documentId
    yield put(webChatStoreUpdated(documentId, createWebChatStore()));
    // Each time a new chat is open, retrieve the speech token
    // if the endpoint is speech enabled and create a bound speech
    // pony fill factory. This is consumed by WebChat...
    yield put(webSpeechFactoryUpdated(documentId, undefined)); // remove the old factory
    const conversationId = yield select(getConversationIdFromDocumentId, documentId);
    // Try the bot file
    let endpoint: IEndpointService = yield select(getEndpointServiceByDocumentId, documentId);
    // Not there. Try the service
    if (!endpoint) {
      try {
        const serverUrl = yield select((state: RootState) => state.clientAwareSettings.serverUrl);
        const endpointResponse: Response = yield ConversationService.getConversationEndpoint(serverUrl, conversationId);
        if (!endpointResponse.ok) {
          const error = yield endpointResponse.json();
          throw new Error(error.error.message);
        }
github microsoft / BotFramework-WebChat / packages / component / src / Middleware / CardAction / createCoreMiddleware.js View on Github external
return ({ dispatch }) => next => ({ cardAction, getSignInUrl }) => {
    const { displayText, text, type, value } = cardAction;

    switch (type) {
      case 'imBack':
        if (typeof value === 'string') {
          // TODO: [P4] Instead of calling dispatch, we should move to dispatchers instead for completeness
          dispatch(sendMessage(value, 'imBack'));
        } else {
          throw new Error('cannot send "imBack" with a non-string value');
        }

        break;

      case 'messageBack':
        dispatch(sendMessageBack(value, text, displayText));

        break;

      case 'postBack':
        dispatch(sendPostBack(value));

        break;
github microsoft / BotFramework-WebChat / packages / component / src / Middleware / CardAction / createCoreMiddleware.js View on Github external
return ({ dispatch }) => next => ({ cardAction, getSignInUrl }) => {
    const { displayText, text, type, value } = cardAction;

    switch (type) {
      case 'imBack':
        if (typeof value === 'string') {
          // TODO: [P4] Instead of calling dispatch, we should move to dispatchers instead for completeness
          dispatch(sendMessage(value, 'imBack'));
        } else {
          throw new Error('cannot send "imBack" with a non-string value');
        }

        break;

      case 'messageBack':
        dispatch(sendMessageBack(value, text, displayText));

        break;

      case 'postBack':
        dispatch(sendPostBack(value));

        break;

      case 'call':
      case 'downloadFile':
      case 'openUrl':
      case 'playAudio':
      case 'playVideo':
      case 'showImage':
        window.open(value);
        break;
github microsoft / BotFramework-WebChat / packages / component / src / Middleware / CardAction / createCoreMiddleware.js View on Github external
if (typeof value === 'string') {
          // TODO: [P4] Instead of calling dispatch, we should move to dispatchers instead for completeness
          dispatch(sendMessage(value, 'imBack'));
        } else {
          throw new Error('cannot send "imBack" with a non-string value');
        }

        break;

      case 'messageBack':
        dispatch(sendMessageBack(value, text, displayText));

        break;

      case 'postBack':
        dispatch(sendPostBack(value));

        break;

      case 'call':
      case 'downloadFile':
      case 'openUrl':
      case 'playAudio':
      case 'playVideo':
      case 'showImage':
        window.open(value);
        break;

      case 'signin': {
        // TODO: [P3] We should prime the URL into the OAuthCard directly, instead of calling getSessionId on-demand
        //       This is to eliminate the delay between window.open() and location.href call
github microsoft / BotFramework-WebChat / packages / component / src / Composer.js View on Github external
  const memoizedStore = useMemo(() => store || createStore(), [store]);
github microsoft / BotFramework-WebChat / packages / component / src / Composer.js View on Github external
useEffect(() => {
    dispatch(setLanguage(locale));
  }, [dispatch, locale]);
github microsoft / BotFramework-WebChat / packages / component / src / Composer.js View on Github external
useEffect(() => {
    dispatch(setSendTimeout(sendTimeout));
  }, [dispatch, sendTimeout]);
github microsoft / BotFramework-WebChat / packages / component / src / Composer.js View on Github external
useEffect(() => {
    dispatch(setSendTypingIndicator(!!patchedSendTypingIndicator));
  }, [dispatch, patchedSendTypingIndicator]);