microsoft/BotFramework-DirectLineJS

Problem creating new object of new DirectLine and throwing error not implemented

viksyy opened this issue · 10 comments

Hello,

I have instaled botframework-directlinejs version 0.14.1 and while importing in my React Native application and instantiate the object new DirectLine I experienced this error: Error not implemented and after every refresh, I got this message in my terminal Invariant violation: module AppRegistry is not a registered callable module (calling runapplication)
I don't have a problem with getting error while connecting or something like this while posting the message or receiving. I have a problem while loading the app (const directLine = new DirectLine({ secret: "YOUR_SECRET_GOES_HERE" });)

Example code:

import { DirectLine } from "botframework-directlinejs";
const directLine = new DirectLine({ secret: "YOUR_SECRET_GOES_HERE" });
...

directLine.activity$.subscribe(botMessage => { this.setState({ messages: [botMessage, ...this.state.messages] }); });
...
directLine .postActivity(giftedMessageToBotMessage(message)) .subscribe(() => console.log("success"), (err) => console.log("failed", err));

I downgrade the library to version 0.9.15 and achieved everything that I need for bot chatting

If there is something new about this problem please inform me
Thanks

Thank you for the report, @viktorspasevski

Can you provide repro steps and a stack trace?

import React from "react";
import { StyleSheet, Text, View } from "react-native";
import { GiftedChat } from "react-native-gifted-chat";
import * as dl from "botframework-directlinejs";
const directLine = new dl.DirectLine({
  secret: "YOUR_SECRET_GOES_HERE"
});

const botMessageToGiftedMessage = botMessage => ({
  ...botMessage,
  _id: botMessage.id,
  createdAt: botMessage.timestamp,
  user: {
    _id: 2,
    name: "React Native",
    avatar:
      "https://cdn.iconscout.com/public/images/icon/free/png-512/avatar-user-business-man-399587fe24739d5a-512x512.png"
  }
});
function giftedMessageToBotMessage(message) {
  return {
    from: { id: 1, name: "John Doe" },
    type: "message",
    text: message.text
  };
}
export default class App extends React.Component {
  state = {
    messages: []
  };
constructor(props) {
    super(props);
    directLine.activity$.subscribe(botMessage => {
      const newMessage = botMessageToGiftedMessage(botMessage);
      this.setState({ messages: [newMessage, ...this.state.messages] });
    });
  }
onSend = messages => {
    this.setState({ messages: [...messages, ...this.state.messages] });
    messages.forEach(message => {
      directLine
        .postActivity(giftedMessageToBotMessage(message))
        .subscribe(() => console.log("success"), () => console.log("failed"));
    });
  };
render() {
    return (
      <View style={styles.container}>
        <GiftedChat
          user={{
            _id: 1
          }}
          messages={this.state.messages}
          onSend={this.onSend}
        />
      </View>
    );
  }
}
const styles = StyleSheet.create({
  container: {
    flex: 1
  }
});

image

This is the code and the error received when I imported the lib

@viktorspasevski - Thank you. May I have some repro steps please?

I can suggest these repro steps (not special)

  • Get the above code that I mentioned
  • Paste in your file
  • Save the file
  • Reload the application
  • The error will be shown up in the terminal and/or red screen on the emulator/phone

I am receiving the error Error not implemented

@viktorspasevski - I'm sorry, but I don't think those repro steps will be adequate. You mention reloading an application but you haven't mentioned creating an application. I'm looking for the kind of detailed repro steps that involve starting from scratch, since creating a React Native app is outside the scope of this repo. Please feel free to link to external instructions so long as you're clear about how you've used those instructions.

I am so sorry about that. I followed this example (https://blog.expo.io/so-you-want-to-build-a-chat-app-with-react-native-expo-and-microsofts-bot-framework-4d2327f76ce3) and I got the error that I forwarded to you

@viktorspasevski - Those instructions look outdated in a few ways. The instructions ask you to use the Expo XDE, though there is no longer an Expo XDE. Were you able to follow the instructions as written, or did you have to modify them?

@viktorspasevski - Are you still working on this?

I am closing this issue due to inactivity. We are still happy to provide help if you need any, though it may be a good idea to make a new post if that's the case. Please have a look at this to find out the best places to ask for help, and consider asking questions on Stack Overflow.

I have a similar problem and my native modules become completely uncomfortable after adding this library and I still could not solve it.